import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;              
import java.awt.event.*;       
import java.net.URL;
import java.io.*;
import java.lang.Object;
import java.util.Properties;
 
 
//formatka wyboru formatu transmisji

class FormatFrame extends JFrame{
	
	Properties wlasciwosci = PropertyLoader.load("conf/System.properties"); 
	final JCheckBox F1Box = new JCheckBox("JPEG_RTP");
        final JCheckBox F2Box = new JCheckBox("H263.RTP");
        String FORMAT_VIDEO = wlasciwosci.getProperty("FORMAT.VIDEO");
                
public FormatFrame(){
	
       if(FORMAT_VIDEO.equals("VideoFormat.JPEG_RTP")){
                F1Box.setSelected(true);
                }else {F2Box.setSelected(true);}
       
       setTitle("Okno wyboru formatu video");
       setResizable(false);
       setSize(450,100);
       setLocation(260,0);
       JLabel text1 = new JLabel(" Wybierz format transmisji (JPEG_RTP - dla LAN, H263_RTP - dla WAN)");
         
        getContentPane().add(text1,BorderLayout.CENTER);
        F1Box.addActionListener(new ActionListener(){
                		
        	
public void actionPerformed(ActionEvent e){
                        
		F1Box.updateUI();
        if (F1Box.isSelected()){
    	F2Box.setSelected(false);}
    	 else F2Box.setSelected(true);
       try{
        wlasciwosci.setProperty("FORMAT.VIDEO","VideoFormat.JPEG_RTP");
        FileOutputStream os = new FileOutputStream("conf/System.properties");
        wlasciwosci.store(os,"Zmiana ustawien");
        //FORMAT_VIDEO = wlasciwosci.getProperty("FORMAT.VIDEO");
        }catch(FileNotFoundException fnfe){}
      catch(IOException ioe){}
        }
        });
                
F2Box.addActionListener(new ActionListener(){
                
public void actionPerformed(ActionEvent e){
	
      	F2Box.updateUI(); //Aktualizacja stanu
       try{
	   wlasciwosci.setProperty("FORMAT.VIDEO","VideoFormat.H263_RTP");
	   FileOutputStream os = new FileOutputStream("conf/System.properties");
	   wlasciwosci.store(os,"Zmiana ustawien");
	   //FORMAT_VIDEO = wlasciwosci.getProperty("FORMAT.VIDEO");
        }catch(FileNotFoundException fnfe){}
      catch(IOException ioe){}
                      
      //Wylaczania opcji wyboru jezeli zaznaczony
      if (F2Box.isSelected()==true){
    	  F1Box.setSelected(false);	
	}
	else F1Box.setSelected(true);
    }
	});
                
                
    F2Box.isValid();      
    JPanel FPanel = new JPanel();
    FPanel.add(F1Box);
    FPanel.add(F2Box);
    getContentPane().add(FPanel,BorderLayout.SOUTH);
                }
	}
